# 导入base模块
from common.base import Base, By, time


# TODO 定义LoginPage类，继承Base类
class LoginPage(Base):
    # TODO 定位账号输入框，输入数据
    def input_username(self, username, values):
        """
        调用Base里location_element方法
                attribute_element方法
        """
        self.location_element(values).send_keys(username)

    # TODO 定位密码输入框，输入数据
    def input_password(self, password, values):
        """
        调用Base里location_element方法
        """
        self.location_element(values).send_keys(password)

    # TODO 定位保存信息框，点击
    def remember(self):
        """
        调用Base里click方法
        """
        self.click((By.NAME, 'remember'))

    # TODO 定位登录按钮，点击
    def btn_login(self):
        self.click((By.NAME, 'submit'))


if __name__ == '__main__':
    ca = LoginPage('chrome')

    ca.get_website('https://ecshop.test2.shopex123.com/user.php')

    ca.input_username(username='大大怪', values=(By.NAME, 'username'))

    ca.input_password(password='123456', values=(By.NAME, 'password'))
    # ca.remember()
    # ca.btn_login()
    # time.sleep(2)
    # ca.retreat()
    # time.sleep(2)
    # ca.forward()
    # time.sleep(2)
    # ca.refresh()
    ca.quit(5)
